package com.edu.d2_static_util;

public class ArrayUtils {
    /**
     * toString工具类，将数组输出成字符串
     * @param a 数组
     * @return 数组拼接成的字符串
     */
    public static String tostring(int[] a){
        String ch="";
        for (int i = 0; i < a.length; i++) {
            ch+=a[i];
        }
        return ch;
    }
    public static double getAverage(int[] a) {
        double sum = 0;
        //循环排序
        for (int i = 0; i < a.length; i++) {
            for (int j = 0; j <a.length - i-1; j++) {
                if (a[j] > a[j + 1]) {
                    int temp = a[j];
                    a[j] = a[j + 1];
                    a[j + 1] = temp;
                }
            }
        }
        for (int i = 1; i < a.length-1; i++) {
            sum += a[i];
        }
        return sum / (a.length-2);
    }
}
